package com.frogs.ucenter.v1.service.impl;

import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.frogs.framework.base.dao.BaseDao;
import com.frogs.framework.base.service.daoimpl.BaseServiceImpl;
import com.frogs.framework.util.PageList;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.api.response.Response;
import com.frogs.system.web.api.response.Response.ApiResultEnum;
import com.frogs.system.web.exception.ServiceOperationException;
import com.frogs.ucenter.dao.QuestionExamineDao;
import com.frogs.ucenter.entity.QuestionExamine;
import com.frogs.ucenter.entity.QuestionExamine;
import com.frogs.ucenter.v1.request.QEAddRequest;
import com.frogs.ucenter.v1.request.SmsCheckRequest;
import com.frogs.ucenter.v1.response.DefaultResponse;
import com.frogs.ucenter.v1.service.QuestionExamineService;
import com.frogs.ucenter.v1.util.ApiConstants;

@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class) 
@Service(ApiConstants.VERSION + "questionExamineService")
public class QuestionExamineServiceImpl extends BaseServiceImpl<QuestionExamine> implements QuestionExamineService {
	
	private static final Logger log = LoggerFactory.getLogger(QuestionExamineServiceImpl.class);
	
    @Autowired
    private QuestionExamineDao questionExamineDao;

    public QuestionExamineServiceImpl() {
        super();
    }

    public QuestionExamineDao getQuestionExamineDao() {
        return questionExamineDao;
    }

    /**
     * Don't remove or edit it.
     */
    @Override
    protected BaseDao<QuestionExamine> getBaseDao() {
        return questionExamineDao;
    }

    public void setQuestionExamineDao(QuestionExamineDao questionExamineDao) {
        this.questionExamineDao = questionExamineDao;
    }
    
    

	
	@Override
	public Response addQuestionExamine(Request request) throws Exception {
		Response response = new DefaultResponse();
		try {
			QEAddRequest udr = (QEAddRequest)request;

				QuestionExamine ul = new QuestionExamine();
				ul.setUserId(udr.getUserId());
				ul.setOpenId(udr.getOpenId());
				ul.setWechatAccount(udr.getWechatAccount());
				ul.setDataTypeId(udr.getDataTypeId());
				ul.setContent(udr.getContent());
				questionExamineDao.insert(ul);
			
		} catch (Exception e) {
			log.error("func[{}] request[{}] exception[{}] desc[fail]",
					new Object[] { this.getClass().getName() +"."+Thread.currentThread().getStackTrace()[1].getMethodName(),
						request,Arrays.deepToString(e.getStackTrace()) });
			throw new ServiceOperationException("请求处理失败：" + e.getMessage());
		}
		
		
		return response;
	}
	
}